import fang_rental from '../src/data/house/fang_rental.json';
import fang_second_house from '../src/data/house/fang_second_house.json';

export default {
  // 出租房列表
  'GET /getzu': fang_rental,
  // 二手房列表
  'GET /getsecond': fang_second_house,
  // 游客搜索
  'GET /getsecondListShai': (req: any, res: any) => {
    const { search } = req.query;
    if (search) {
      const arr = fang_second_house.RECORDS.filter((item: any) => {
        return item.title.includes(search);
      });
      res.send(arr);
    } else {
      res.send(fang_second_house.RECORDS);
    }
  },
  'GET /getzuListShai': (req: any, res: any) => {
    const { search } = req.query;
    if (search) {
      const arr = fang_rental.RECORDS.filter((item: any) => {
        return item.title.includes(search);
      });
      res.send(arr);
    } else {
      res.send(fang_rental.RECORDS);
    }
  },
};
